package org.karesz.services;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import org.karesz.dao.JbossUserDaoImpl;
import org.karesz.model.User;


@ManagedBean
@RequestScoped
public class JbossUserServices {

	@EJB
	JbossUserDaoImpl dao;
	
	public User user;
/*
	@PostConstruct
	private void init(){
		dao = new JbossUserDaoImpl();
	}
	*/
	public User getUser() {
		if(user == null) user = new User();
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	
	public String action(){
	
		System.out.println("JSF ACTION !!");
		//this.getUser().setName("JPA Mysql Karesz");
	//	dao.save(this.getUser());
		
		System.out.println("Step1");
		dao.save(this.getUser());
		
		System.out.println("Step2");
		
	//	dao.save(this.getUser());
		System.out.println("Step3");
		
		
		System.out.println("Step4");
		
		
		
		
		
		return "#";
	}
	
}
